package mi.top.utils;

import javax.swing.*;
import java.awt.event.ActionEvent;

/**
 * @author 祥霸
 * @date 2021.07.13
 *
 */
public class MainSwing extends JFrame {

    /** 菜单条*/
    private JMenuBar menubar;
    /** 菜单*/
    private JMenu menuFile;
    /** 菜单项*/
    private JMenuItem itemOpen;

    public static void main(String[] args) {
//        RasterSwing rasterSwing = new RasterSwing();
//        rasterSwing.init();
//
//        AlarmSwing alarmSwing = new AlarmSwing();
//        alarmSwing.init();

//        CombinationSwing combinationSwing = new CombinationSwing();
//        combinationSwing.setTitle("设备组1");

        MainSwing main = new MainSwing();
        main.setTitle("main");
        main.init();
    }

    public void init() {

        menubar = new JMenuBar();
        menuFile = new JMenu("菜单");
        itemOpen = new JMenuItem("创建");

        menuFile.add(itemOpen);
        menubar.add(menuFile);
        setJMenuBar(menubar);

        itemOpen.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("--");
                String s = JOptionPane.showInputDialog("");
                System.out.println(s);
                if(s == null) {
                    return;
                }

                new CombinationSwing(s, JFrame.HIDE_ON_CLOSE);

            }
        });

        JLabel label = new JLabel("Welcome to HANGZHOU");

        this.getContentPane().add(label);

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setSize(266, 150);
    }

}
